package com.myproject.musicrecommendationsystem.controller;

import com.myproject.musicrecommendationsystem.domain.Song;
import com.myproject.musicrecommendationsystem.service.SongService;
import com.myproject.musicrecommendationsystem.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(tags="歌曲功能(0729单禹铭)")
public class SongController {
    @Autowired
    private SongService service;
    @PostMapping("/addSong")
    @ApiOperation("添加歌曲")
    public AjaxResult addSong(Song song){
        return AjaxResult.success(service.insert(song));
    }
    @DeleteMapping ("/deleteSong")
    @ApiOperation("删除歌曲")
    public AjaxResult deleteSong(int id){
        return AjaxResult.success(service.deleteById(id));
    }
    @PostMapping("/updateSongById")
    @ApiOperation("修改歌曲信息")
    public AjaxResult updateSongById(Song song){
        return AjaxResult.success(service.IupdateById(song));
    }
    @GetMapping("/selectSongs")
    @ApiOperation("搜索歌曲")
    public AjaxResult selectSongs( Song song,int page,int size){
        return AjaxResult.success(service.getSongList(song,page,size));
    }


}
